# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python

class Recipe(recipe.Recipe):
    name = 'zbar'
    version = '0.23'
    stype = SourceType.TARBALL
    url = 'https://linuxtv.org/downloads/zbar/zbar-%(version)s.tar.gz'
    tarball_checksum = 'ac52763a7dd6ddc53ca6cd75ccee14f7abf6ae46ecb31137d025af123edd33bf'
    configure_options = '--disable-pthread --disable-video --without-imagemagick --without-gtk --without-qt --with-python=no --with-jpeg=no --with-x=no'
    files_libs = ['libzbar']
    files_devel = ['include/zbar.h', 'lib/pkgconfig/zbar.pc']

    def prepare(self):
        if self.config.target_platform in (Platform.WINDOWS, Platform.ANDROID):
            self.deps.append('libiconv')
        if self.config.target_platform == Platform.WINDOWS:
            # This flag should be removed in 0.24
            self.append_env('CFLAGS', '-std=c99')
            # zbar incorrectly passes CPPFLAGS to WINDRES, which then barfs on
            # args it can't understand
            self.set_env('CPPFLAGS', '')
        if self.config.target_platform in [Platform.IOS, Platform.DARWIN]:
            self.autoreconf = True
